load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//def:ts.bzl", "rollup_bundle", "ts_library")

go_library(
    name = "go_default_library",
    srcs = ["lens.go"],
    importpath = "k8s.io/test-infra/prow/spyglass/lenses/junit",
    visibility = ["//visibility:public"],
    deps = [
        "//prow/spyglass/api:go_default_library",
        "//prow/spyglass/lenses:go_default_library",
        "@com_github_googlecloudplatform_testgrid//metadata/junit:go_default_library",
        "@com_github_sirupsen_logrus//:go_default_library",
    ],
)

ts_library(
    name = "script",
    srcs = ["lens.ts"],
    deps = [
        "//prow/spyglass/lenses:lens_api",
    ],
)

rollup_bundle(
    name = "script_bundle",
    entry_point = ":lens.ts",
    deps = [
        ":script",
    ],
)

filegroup(
    name = "resources",
    srcs = [
        "junit.css",
        ":script_bundle.min",
    ],
    visibility = ["//visibility:public"],
)

filegroup(
    name = "template",
    srcs = ["template.html"],
    visibility = ["//visibility:public"],
)

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [":package-srcs"],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)

go_test(
    name = "go_default_test",
    srcs = ["lens_test.go"],
    embed = [":go_default_library"],
    deps = [
        "//prow/spyglass/api:go_default_library",
        "//prow/spyglass/lenses:go_default_library",
        "@com_github_google_go_cmp//cmp:go_default_library",
        "@com_github_googlecloudplatform_testgrid//metadata/junit:go_default_library",
    ],
)
